package com.china08.yxyapi.api.manage.tec.teaching.homework.myques;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.db.res.YxyResSubject;
import com.china08.yxyapi.repository.db.YxyResSubjectRepository;

import io.swagger.annotations.ApiOperation;

@CrossOrigin
@RestController
public class HomeworkSubjectNameController extends YxyApiBaseController {

    @Autowired
    private YxyResSubjectRepository yxyResSubjectRepository;

    @ApiOperation(value = "获取学科名称")
    @RequestMapping(value = "/api_yw/manage/tec/teaching/homework/mysql/subject/{subject}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespModel process(HttpServletRequest request, HttpServletResponse response,
            @PathVariable(value = "subject") String subject) {
        YxyResSubject resSubject = yxyResSubjectRepository.findById(subject);
        RespModel model = new RespModel();
        model.name = resSubject.getName();
        return model;
    }

    protected static class RespModel {
        public String name;
    }

}
